package com.otherTest.enums;


import org.junit.Test;

import java.util.Arrays;

import static com.otherTest.enums.AgainEnum.FEE;
import static com.otherTest.enums.AgainEnum.TEAM;

/**
 * @Description:
 * @author: conceit
 * @Date: 2018/7/18 0018
 */
public class AgainTestEnum {

    private static String prinln="----- ---------------------------------------------------------------------------";

    @Test
    public void doTest(){

        System.out.println("自带方法"+prinln);
        System.out.println(AgainEnum.keyOf(1));

        System.out.println("输出全部的枚举值"+prinln);
        Arrays.stream(AgainEnum.values()).forEach(System.out::println);

        System.out.println("获取指定的枚举值  以及对应的key和explain"+prinln);
        System.out.println(AgainEnum.valueOf("FEE"));
        System.out.println(AgainEnum.valueOf("FEE").key);
        System.out.println(AgainEnum.valueOf("FEE").getKey());
        System.out.println(AgainEnum.valueOf("FEE").explain);
        System.out.println(AgainEnum.valueOf("FEE").getExplain());

        System.out.println("获取指定的枚举值,基本等同与上个方法"+prinln);
        System.out.println(AgainEnum.INVITE);

        System.out.println("获取指定的枚举值的顺序 从0 开始"+prinln);
        System.out.println(AgainEnum.INVITE.ordinal());

        System.out.println("输出指定的枚举值(自定义异常可以这么指定)"+prinln);
        System.out.print(AgainEnum.FEE.name());


    }

    @Test
    public void doTestSwitch(){
        AgainEnum testSwitch=AgainEnum.FEE;
        switch (testSwitch){
            case FEE:
                System.out.println(FEE);
                break;
            case TEAM:
                System.out.println(TEAM);
                break;
            default:
                System.out.println("default");
                break;

        }
    }
}
